import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { BrowserModule } from '@angular/platform-browser';


// 登录，注册，密码重置
import { LoginPage } from './pages/login/login.page';
import { RegPage } from './pages/reg/reg.page';
import { ForgetPage } from './pages/forget/forget.page';
import { ManhuaPage } from './pages/manhua/manhua.page';
import { UserPage } from './pages/user/user.page';

export const routingPages = [LoginPage, RegPage, ForgetPage, ManhuaPage, UserPage];
// provider

// chilren
import { ManhuaTable } from './pages/manhua/table/manhua.table';
import { ManhuaDetail } from './pages/manhua/detail/manhua.detail';
import { ManhuaFavorComponent } from './component/manhua-favor/manhua-favor';
import { ManhuaSearch } from './pages/manhua/search/manhua.search';
import { UserFavors } from './pages/user/favors/user.favors';
import { UserVerifyProvider } from './util/user-verify.provider';
import { UserHistorys } from './pages/user/historys/user.historys';
import { ManhuaDeleteComponent } from './component/manhua-delete/manhua.delete';
import { ManhuaImage } from './pages/manhua/image/manhua.image';


// directive
import { DefaultImageDirective } from './directive/imgLoading';

export const routingPagesComponents = [ManhuaTable, ManhuaDetail, ManhuaImage, ManhuaFavorComponent, ManhuaSearch, UserFavors, UserHistorys, ManhuaDeleteComponent, DefaultImageDirective];

const routes: Routes = [
  // index
  {
    path: 'manhua', component: ManhuaPage
  },
  {
    path: 'manhua/:title', component: ManhuaDetail
  },
  {
    path: 'manhua/:title/:chapter', component: ManhuaImage
  },
  {
    path: 'search', component: ManhuaSearch
  },
  {
    path: 'user', component: UserPage, canActivate: [UserVerifyProvider],
    children: [
      { path: 'favors', component: UserFavors },
      { path: 'historys', component: UserHistorys },
      { path: '**', redirectTo: "favors" }
    ]
  },
  /*{
    path: 'word/:words', component: WordDetailPage, canActivate: [AuthGuard]
    , children: [
      { path: 'sell', component: WordDetailHistoryComponent },
      // { path: 'category', component: BrandPieComponent },
      // { path: 'shop', component: BrandShopComponent },
      { path: 'product', component: WordDetailProductComponent },
      // { path: 'doubleProduct', component: DoubleBrandProductComponent },
      { path: '**', redirectTo: "sell" }
    ]
  
  }, */
  { path: 'login', component: LoginPage },
  { path: 'reg', component: RegPage },
  { path: 'forget', component: ForgetPage },
  { path: '', redirectTo: "/manhua", pathMatch: 'full' },
  { path: '**', redirectTo: "/manhua" }
];

@NgModule({
  imports: [BrowserModule, BrowserAnimationsModule, RouterModule.forRoot(routes)],
  exports: [RouterModule],
  providers: []
})
export class AppRoutingModule { }
